class Solution(object):
    def isPalindrome(self, s):
        """
        :type s: str
        :rtype: bool
        """
        s = s.lower()
        left_index = 0
        right_index = len(s) - 1
        while right_index > left_index:
            if not (97 <= ord(s[left_index]) <= 122 or 48 <= ord(s[left_index]) <= 57):
                left_index += 1
            else:
                if not (97 <= ord(s[right_index]) <= 122 or 48 <= ord(s[right_index]) <= 57):
                    right_index -= 1
                else:
                    if s[left_index] == s[right_index]:
                        left_index += 1
                        right_index -= 1
                    else:
                        return False
        return True


data = Solution()
s = "race e car"
print(data.isPalindrome(s))
